/*
Copyright (C) 2009  Raymond Jeon
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/


#ifndef __GL_LIB_GLLOCK_H__
#define __GL_LIB_GLLOCK_H__


#include "gl_lib_define.h"

#ifdef WIN32

#define glmutex_				CRITICAL_SECTION
#define GlMutexInit(pMt)		InitializeCriticalSection(pMt)
#define GlMutexDestroy(pMt)		DeleteCriticalSection(pMt)
#define GlMutexLock(pMt)		EnterCriticalSection(pMt)
#define GlMutexTryLock(pMt)		TryEnterCriticalSection(pMt)
#define GlMutexUnLock(pMt)		LeaveCriticalSection(pMt)

#else

#ifdef _SOLARIS_

#define glmutex_				mutex_t
#define GlMutexInit(pMt)		mutex_init(pMt, USYNC_THREAD, NULL)
#define GlMutexDestroy(pMt)		mutex_destroy(pMt)
#define GlMutexLock(pMt)		mutex_lock(pMt)
#define GlMutexTryLock(pMt)		mutex_trylock(pMt)
#define GlMutexUnLock(pMt)		mutex_unlock(pMt)

#else

#define glmutex_				pthread_mutex_t
#define GlMutexInit(pMt)		pthread_mutex_init_define(pMt)
#define GlMutexDestroy(pMt)		pthread_mutex_destroy(pMt)
#define GlMutexLock(pMt)		pthread_mutex_lock(pMt)
#define GlMutexTryLock(pMt)		pthread_mutex_trylock(pMt)
#define GlMutexUnLock(pMt)		pthread_mutex_unlock(pMt)

#endif	// _SOLARIS_

#endif	// WIN32


typedef int	HLOCK;

HLOCK GlFileLock(char *szFile);
void GlFileUnLock(char *szFile, HLOCK h);







#endif	// __GL_LIB_GLLOCK_H__